package com.zdy.config;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * @Author: Deyou
 * @Date: 2021/4/14
 */

/**
 * 数据源配置
 */
@Configuration
public class DataSourceConfig {

    /*
    * 配置主数据源
    * */
    @Bean("dataSource01")

    @Primary
    @ConfigurationProperties(prefix = "spring.datasource.shiyanlou01")
    public DataSource getDataSource01(){
        return DataSourceBuilder.create().build();
    }
    @Bean("dataSource02")

    /***
     * 配置第二数据源
     */
    @ConfigurationProperties(prefix = "spring.datasource.shiyanlou02")
    public DataSource getDataSource02(){
        return DataSourceBuilder.create().build();
    }
}
